package com.task.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.util.ObjectUtils;

/**
 * @Author 迪迦.
 * @Date 2023/5/18 17:41
 */
public enum MissionSearchTimeEnum {
  //,,,,,,,,,,,,Custom Date,Custom Time
  TODAY(0, "Today", "Today"),
  YESTERDAY(1, "Yesterday", "Yesterday"),
  THIS_WEEK(2, "This Week", "This Week"),
  LAST_2_DAYS(3, "Last 2 Days", "Last 2 Days"),
  LAST_3_DAYS(4, "Last 3 Days", "Last 3 Days"),
  LAST_7_DAYS(5, "Last 7 Days", "Last 7 Days"),
  LAST_14_DAYS(6, "Last 14 Days", "Last 14 Days"),
  THIS_MONTH(7, "This Month", "This Month"),
  LAST_MONTH(8, "Last Month", "Last Month"),
  THIS_YEAR(9, "This Year", "This Year"),
  LAST_YEAR(10, "Last Year", "Last Year"),
  ALL_TIME(11, "All Time", "All Time"),
  //TODAY(0, "Today", "Today", false),
  //TODAY(0, "Today", "Today", false),
  //TODAY(0, "Today", "Today", false),
  //TODAY(0, "Today", "Today", false),

  ;

  private Integer info;
  private String displayName;
  private String msg;


  MissionSearchTimeEnum(Integer info, String displayName, String msg) {
    this.info = info;
    this.displayName = displayName;
    this.msg = msg;
  }

  public static MissionSearchTimeEnum getEnumByInfo(int info) {
    if (!ObjectUtils.isEmpty(info)) {
      for (MissionSearchTimeEnum value : MissionSearchTimeEnum.values()) {
        if (info == value.getInfo()) {
          return value;
        }
      }
    }
    return null;
  }

  public static MissionSearchTimeEnum getEnumByName(String name) {
    if (!ObjectUtils.isEmpty(name)) {
      for (MissionSearchTimeEnum value : MissionSearchTimeEnum.values()) {
        if (name.equals(value.name())) {
          return value;
        }
      }
    }
    return null;
  }

  /**
   * 获取列表.
   */
  public static List<Map<String, Object>> getList() {
    List<Map<String, Object>> list = new ArrayList<>();
    for (MissionSearchTimeEnum value : MissionSearchTimeEnum.values()) {
      Map<String, Object> map = new HashMap<>();
      map.put("value", value.name());
      map.put("label", value.getMsg());
      map.put("displayName", value.getDisplayName());
      list.add(map);
    }
    return list;
  }

  MissionSearchTimeEnum() {
  }

  public Integer getInfo() {
    return info;
  }

  public String getDisplayName() {
    return displayName;
  }

  public String getMsg() {
    return msg;
  }
}
